import { NodeSize } from '../config'

export default function dummy(flow) {
  flow.register('Dummy', ({ PolygonNode, PolygonNodeModel, h }) => {
    class Node extends PolygonNode {
      getIconShape() {
        return h(
          'svg',
          {
            width: NodeSize,
            height: NodeSize,
            viewBox: '0 0 1024 1024'
          },
          h(
            'path',
            {
              fill: '#EFF9FE',
              d: 'M531.992381 135.728762c-143.408762 0-262.656 119.393524-265.874286 266.118095l-0.438857 13.970286-61.927619 146.895238c-1.340952 3.047619-2.023619 7.119238-1.267809 8.704 0.341333 0.682667 1.633524 1.682286 3.925333 2.608762h59.392v105.886476c0.048762 2.608762 2.023619 67.584 84.650667 90.940952h118.101333v103.228953h217.234286V622.665143l8.825904-5.948953c47.762286-32.182857 103.545905-106.179048 103.545905-208.749714 0-150.113524-119.393524-272.237714-266.166857-272.237714z m-191.804952 331.824762a35.352381 35.352381 0 1 1 0-70.680381 35.352381 35.352381 0 0 1 0 70.680381z m239.128381 67.486476a176.688762 176.688762 0 1 1 0-353.377524 176.688762 176.688762 0 0 1 0 353.377524z'
            }
          ),
          h(
            'path',
            {
              fill: '#3D6480',
              d: 'M531.992381 95.670857c-165.010286 0-302.226286 136.97219-305.90781 305.103238l-0.195047 6.363429-58.636191 139.142095c-1.048381 2.194286-10.020571 21.918476-1.389714 41.374476 3.803429 8.533333 12.336762 19.919238 31.524571 25.624381l28.355048 0.828953v65.828571c0 34.255238 24.405333 105.593905 116.833524 130.31619l85.918476 0.682667v103.253333h297.350095V643.608381c53.711238-40.472381 112.37181-123.538286 112.37181-235.641905 0-172.202667-137.362286-312.295619-306.224762-312.295619z m162.645333 521.045333l-8.825904 5.948953v251.465143h-217.234286v-103.228953h-118.101334c-82.627048-23.356952-84.601905-88.33219-84.650666-90.940952v-105.886476H206.409143c-2.29181-0.926476-3.584-1.926095-3.925333-2.608762-0.731429-1.584762-0.073143-5.656381 1.267809-8.704l61.927619-146.895238 0.438857-13.970286c3.193905-146.724571 122.465524-266.118095 265.874286-266.118095 146.773333 0 266.166857 122.12419 266.166857 272.262095 0 102.473143-55.759238 176.493714-103.521524 208.676571z'
            }
          ),
          h(
            'path',
            {
              fill: '#3D6480',
              d: 'M340.187429 432.225524m-35.328 0a35.328 35.328 0 1 0 70.656 0 35.328 35.328 0 1 0-70.656 0Z'
            }
          ),
          h(
            'path',
            {
              fill: '#FFFFFF',
              d: 'M570.319238 480.792381v-113.420191h-113.444571a122.782476 122.782476 0 0 0 113.444571 113.420191z'
            }
          ),
          h(
            'path',
            {
              fill: '#FFFFFF',
              d: 'M579.31581 181.686857a176.713143 176.713143 0 1 0 0.02438 353.401905 176.713143 176.713143 0 0 0-0.02438-353.401905z m140.848761 185.685333a141.336381 141.336381 0 0 1-131.876571 131.876572v23.966476h-17.993143v-23.966476a141.287619 141.287619 0 0 1-131.876571-131.876572H414.47619v-17.993142h23.966477a141.312 141.312 0 0 1 131.876571-131.900953v-23.917714h17.993143v23.942095a141.312 141.312 0 0 1 131.876571 131.900953h23.966477v17.993142h-23.990858z'
            }
          ),
          h(
            'path',
            {
              fill: '#FFFFFF',
              d: 'M588.312381 235.958857v113.444572h113.42019a122.733714 122.733714 0 0 0-113.42019-113.444572z'
            }
          ),
          h(
            'path',
            {
              fill: '#3D6480',
              d: 'M720.164571 349.379048a141.336381 141.336381 0 0 0-131.876571-131.900953v-23.917714h-17.993143v23.942095a141.312 141.312 0 0 0-131.876571 131.900953H414.47619v17.993142h23.966477a141.312 141.312 0 0 0 131.876571 131.876572v23.966476h17.993143v-23.966476a141.336381 141.336381 0 0 0 131.876571-131.876572h23.966477v-18.017523h-23.990858z m-149.845333 131.413333a122.782476 122.782476 0 0 1-113.444571-113.420191h113.444571v113.420191z m17.993143-131.413333V235.958857a122.782476 122.782476 0 0 1 113.42019 113.444572H588.312381z'
            }
          )
        )
      }

      getLabelShape() {
        return h(
          'text',
          {
            fill: '#000000',
            fontSize: 12,
            x: NodeSize / 2,
            y: NodeSize + 20,
            textAnchor: 'middle',
            dominantBaseline: 'middle'
          },
          '空操作'
        )
      }

      getShape() {
        const { x, y, width, height } = this.getAttributes()
        const transform = `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`
        return h(
          'g',
          {
            transform
          },
          [
            h(
              'rect',
              {
                rx: 5,
                ry: 5,
                width: NodeSize,
                height: NodeSize,
                fill: '#fff',
                stroke: '#3D6380',
                strokeWidth: 1
              }
            ),
            this.getIconShape(),
            this.getLabelShape()
          ]
        )
      }
    }
    class Model extends PolygonNodeModel {
      constructor(data, graphModel) {
        super(data, graphModel)
        this.points = [
          [NodeSize / 2, 0],
          [NodeSize, NodeSize / 2],
          [NodeSize / 2, NodeSize],
          [0, NodeSize / 2]
        ]
      }
    }

    return {
      view: Node,
      model: Model
    }
  })
}
